package com.xhj.controller;

import com.xhj.service.StatisticsDailyService;
import com.xhj.util.ResultEntity;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 网站统计日数据(StatisticsDaily)表控制层
 *
 * @author makejava
 * @since 2021-03-12 09:49:17
 */
@CrossOrigin
@RestController
@RequestMapping("/statisticsDaily/")
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

    @ApiOperation(value = "根据日期统计数据")
    @RequestMapping("statisticsByDay/{day}")
    public ResultEntity statisticsByDay(@PathVariable String day){
        statisticsDailyService.statisticsByDay(day);
        return ResultEntity.successWithoutData();
    }

    @ApiOperation(value = "根据条件查询统计数据")
    @RequestMapping("getInfo/{begin}/{end}/{type}")
    public ResultEntity showChart(@PathVariable String begin,@PathVariable String end,@PathVariable String type){
        Map<String, Object> map = statisticsDailyService.getChartData(begin,end,type);
        return ResultEntity.successWithData().data("map",map);
    }
}